<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="./inedx.css"/>
</head>
<body>
<div class="static">
    请输入一个数字N:<input type="text" id="tx">
    <input type="button" value="按钮" onclick="fun()"><br>
    答案是：<span class="res"></span>
</div>
<script>
    function fun(){
        var n = document.getElementById("tx").value;
        var k, s=0;
        for(k=1;k<=n;k++){
            s=s+k;
        }
        document.getElementById("res").innerHTML=s;
    }
</script>
</body>
</html>